import { post, get, put, del } from '../utils/request';

/**
 * 设备管理相关API
 */

// 获取设备列表
export const getDeviceList = (params?: {
  page?: number;
  pageSize?: number;
  status?: string;
  type?: string;
  keyword?: string;
}) => {
  return get('/v1/device/list', params);
};

// 获取设备详情
export const getDeviceDetail = (id: string) => {
  return get(`/v1/device/${id}`);
};

// 添加设备
export const addDevice = (data: {
  name: string;
  type: string;
  ip: string;
  location: string;
  description?: string;
}) => {
  return post('/v1/device', data);
};

// 更新设备
export const updateDevice = (id: string, data: {
  name?: string;
  type?: string;
  ip?: string;
  location?: string;
  description?: string;
}) => {
  return put(`/v1/device/${id}`, data);
};

// 删除设备
export const deleteDevice = (id: string) => {
  return del(`/v1/device/${id}`);
};

// 设备状态控制
export const controlDevice = (id: string, action: string) => {
  return post(`/v1/device/${id}/control`, { action });
};

// 获取设备统计数据
export const getDeviceStats = () => {
  return get('/v1/device/stats');
};
